<template>
	<div class="addadmin" id="addadmin">
		<div class="st_t1">
			新增管理员
		</div>
		<div class="admin_info">
			<ul>
				<li>
					<div class="admin_left">账户：</div>
					<div class="admin_right">
						<input type="text" placeholder="请输入..." v-model="info.accountName" />
					</div>
				</li>
				<li>
					<div class="admin_left">姓名：</div>
					<div class="admin_right">
						<input type="text" placeholder="请输入..." v-model="info.userName" />
					</div>
				</li>
				<li>
					<div class="admin_left">密码：</div>
					<div class="admin_right">
						<input type="password" placeholder="请输入..." v-model="info.password" />
					</div>
				</li>
				<li>
					<div class="admin_left">确认密码：</div>
					<div class="admin_right">
						<input type="password" placeholder="请输入..." v-model="true.password" />
					</div>
				</li>
				<li>
					<div class="admin_left">角色：</div>
					<div class="admin_right">
						<select v-model="info.role">
							<option value="0" >超级管理员</option>
							<option value="1">系统管理员</option>
						</select>
					</div>
				</li>
				<li style="height:100px;">
					<div class="admin_left">备注：</div>
					<div class="admin_right">
						<textarea v-model="info.describle"></textarea>
					</div>
				</li>
				<li>
					<button v-on:click="saveInfo()">提交</button>
				</li>
			</ul>
		</div>
	</div>
</template>

<script>
	export default {
		name: 'addadmin',
		computed: {
		},
		data() {
			return {
				title: '',
				trade_index: 1,
				info:{
					accountName:'',
					userName:'',
					password:'',
					role:'0',
					describle:''
				},
				true:{
					password:''
				}
			}
		}, //定义变量
		components: {
			
		}, //注册组件
		methods: {//方法都在这里
			saveInfo:function(){
				var that=this
				var pwd=this.info.password
				var repwd=this.true.password
				if(repwd==pwd){
					this.lh_http('post', "tbLogin/create.do",this.info).done(function(res) {
//						console.log(res)
						if(res.status) {
							alert('添加成功')
							that.$router.push({
								path: '/user/admin'
							})
						} else {
							alert(res.data);
						}
					})
				}else{
					alert('两次输入密码不同')
				}
				
				
			}
		},
		mounted() {
			var that = this;
			//获取banner
		},
	}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style lang="scss">
	.addadmin {
		text-align: left;
		.st_t1 {
			line-height: 40px;
			font-size:24px;
			font-weight: normal;
			background:#ECECEC;
			padding-left:20px;
		}
		.admin_info{
			width:600px;
			margin:40px auto 0;
			ul{
				li{
					width:100%;
					height:40px;
					margin-bottom:30px;
					.admin_left{
						float:left;
						width:100px;
						line-height: 40px;
					}
					.admin_right{
						float:left;
						input{
							width:313px;
							height:36px;
							margin-top:2px;
							border:#ccc solid 1px;
							padding-left:10px;
						}
						select{
							width:313px;
							height:36px;
							margin-top:2px;
							outline: none;
						}
						textarea{
							resize: none;
							width:313px;
							height:100px;
							outline: none;
						}
					}
					button{
						width:313px;
						height:40px;
						background:#007AFF;
						color:#fff;
						border-radius:4px;
						cursor: pointer;
						margin-left:100px;
					}
				}
			} 
		}
	}
</style>